package com.icinfo.cloud.provider.common.qr.controller;

import com.icinfo.cloud.provider.common.constant.Constant;
import com.icinfo.cloud.provider.common.dto.QrCodeQueryDto;
import com.icinfo.cloud.provider.common.oss.service.IOssOperateService;
import com.icinfo.cloud.provider.common.qr.service.IQrService;
import com.icinfo.framework.common.web.Result;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

/**
 * 描述：二维码前端控制器
 *
 * @author xiangyuyu
 * @date 2022/3/12 13:51
 */
@RestController
@RequestMapping("/common/qr")
@Slf4j
public class QrController {
    @Resource
    private IOssOperateService iOssOperateService;
    @Resource
    private IQrService iQrService;

    /**
     * 【V1.0.0】描述：生成二维码
     *
     * @param queryDto {@link QrCodeQueryDto} 二维码查询传输对象
     * @param response {@link HttpServletResponse}
     * @return 二维码信息
     * @author xiangyuyu
     * @date 2022-03-12 14:06
     */
    @PostMapping("/generateQrCode")
    @ApiOperation(value = "【V1.0.0】描述：生成二维码", httpMethod = "POST")
    public Result<String> generateQrCode(@RequestBody @Validated QrCodeQueryDto queryDto, HttpServletResponse response) {
        String qrInfo = iQrService.generateQrCode(queryDto, response);
        return Result.success(Constant.STRING_GET_SUCCESS, qrInfo);
    }
}
